package com.example.logintest01.bean;

import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;




public class MySQLiteOpenHelper extends SQLiteOpenHelper{

    private static final String DB_NAME = "mySQLite.db";
    private static final String TABLE_NAME_STUDENT = "student";
    private static final String CREATE_TABLE_SQL = "create table " + TABLE_NAME_STUDENT +" (id integer primary key autoincrement, name text, number text, gender text, club text);\n";

    public  MySQLiteOpenHelper(Context context){
        super(context, DB_NAME, null, 1);
    }


    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TABLE_SQL);
    }

    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {

    }

    public long insertData(Student student){

        SQLiteDatabase db = getWritableDatabase();

        ContentValues values = new ContentValues();

        values.put("name", student.getName());
        values.put("number", student.getNumber());
        values.put("gender", student.getGender());
        values.put("club", student.getClub());

        return db.insert(TABLE_NAME_STUDENT, null, values);
    }

}
